<?php
/**
 * this class defines the validations that can be expected for a valid User object. 
 * This is based on the default context of how the system will be used
 * At any time a different validator can be used depending on the validations requirements
 *
 */
class profile_validation_Default extends Validator 
{

	public function __construct()
	{
		$this->defineValidations();
	}
	
	/**
	 * this method will be in charge of creating the validator chains that will operate
	 * on the properties of this object
	 *
	 */
	private function defineValidations()
	{
		$this->_definedFields['nickname'] = $this->defineNickname();
	}
	
	/**
	 * validates that a profile object is valid in it's current state
	 *
	 * @param profile_Profile $profile
	 */
	public function validate(profile_Profile $profile)
	{
		$messages = array();
		
		// validate all our defined properties
		foreach($this->_definedFields as $field => $vchain) {
			if(!$vchain->isValid($profile->$field)) {
				$messages = array_merge($messages, $vchain->getMessages());
			}
		}
		// check to make sure the profile is valid as well
		// TODO DO PROFILE CHECKING HERE 

		return $messages;
	}
	

	/**
	 * defines what validator chain to use for an email address
	 *
	 */
	private function defineNickname()
	{
		$validatorChain = new Zend_Validate();
		$validatorChain->addValidator(new  Zend_Validate_StringLength(6));
		return $validatorChain;
	}
	
	
}
?>